<?php


namespace app\admin\model\view;

use app\logic\model\view\DeliverLog_opusNumber_opus_writer_owner;
class DeliverLog_opusNumber_opus_writer_ownerView extends DeliverLog_opusNumber_opus_writer_owner
{
    function getList($request,$limit){
        $list=$this->where(function($q) use ($request){
            if(check_request($request,"opus_title")){
                $q->whereLike("opus_title","%{$request['opus_title']}%");
            }
            if(check_request($request,"writer_name")){
                $q->whereLike("writer_nickname|writer_true_name","%{$request['writer_name']}%");
            }
            if(check_request($request,"owner_mobile")){
                $q->whereLike("owner_mobile","%{$request['owner_mobile']}%");
            }
            if(check_request($request,"status")){
                $q->whereLike("status","%{$request['status']}%");
            }
            if(check_request($request,'start_time')&&check_request($request,'end_time')){
                $q->whereBetween("create_time",[strtotime($request['start_time']),strtotime($request['end_time']." 23:59:59")]);
            }elseif (check_request($request,'start_time')){
                $q->where("create_time",">=",strtotime($request['start_time']));
            }elseif (check_request($request,'end_time')){
                $q->where("create_time","<=",strtotime($request['end_time']." 23:59:59"));
            }
        })
            ->paginate($limit);
        if(!$list->isEmpty()){
            return $list->toArray();
        }else{
            return false;
        }
    }
}